package com.example.dao;

import com.example.domain.Orders;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrderDao {
    @Select("select * from orders limit #{pageCount},#{pageSize}")
    public List<Orders> selectpage(int pageCount,int pageSize);

    @Select("select count(*) from orders")
    public int selectcount();

    @Select("select count(*) from orders where user_id=#{userId}")
    public int selectcount1(Long userId);

    @Insert("insert into orders values (#{id},#{number},#{status},#{userId},#{addressBookId},#{orderTime},#{checkoutTime},#{payMethod},#{amount},#{remark},#{phone},#{address},#{userName},#{consignee})")
    public void save(Orders orders);

    @Select("select * from orders where user_id=#{userId} limit #{pageCount},#{pageSize}")
    public List<Orders> selectall(Long userId,int pageCount,int pageSize);

    @Select("select * from orders where number = #{number} limit #{pageCount},#{pageSize}")
    public Orders selectbynumber(int pageCount,int pageSize,String number);

    @Select("select * from orders where order_time>=#{beginTime} and order_time<=#{endTime}")
    public List<Orders> selectpagebytime(int pageCount, int pageSize, LocalDateTime beginTime,LocalDateTime endTime);

    @Select("select * from orders where number = #{number} and order_time>=#{beginTime} and order_time<=#{endTime} limit #{pageCount},#{pageSize}")
    public Orders selectbynumberandtime(int pageCount,int pageSize,String number,LocalDateTime beginTime,LocalDateTime endTime);
}
